
rev_share <-
  read_csv("./_3_data/revenue_data/farm_revenues.csv") %>%
  dplyr::select(Year, Opium, Salt, Pawnshops, total) %>%
  pivot_longer(cols = Opium:Pawnshops,
               names_to = "Source",
               values_to = "Value") %>%
  mutate(prop = (Value/total)*100) %>%
  ggplot(aes(x=Year, y = prop, linetype = Source, shape = Source)) +
  geom_point(size = 0.1) +
  geom_line() +
  theme_bw() +
  theme(axis.ticks.y.left = element_blank(),
        panel.grid.minor = element_blank(), 
        axis.title.y = element_blank(),
        panel.grid.major.x = element_blank(),
        legend.title = element_blank(),
        axis.title.x = element_blank(),
        axis.line.y.left = element_blank(),
        axis.line = element_line(colour = "black"),
        panel.border = element_blank(),
        panel.background = element_rect(fill = "transparent",colour = NA),
        plot.background = element_rect(fill = "transparent",colour = NA)) +
  theme(text=element_text(size=15))
  


rev_tot <-
  read_csv("./_3_data/revenue_data/farm_revenues.csv") %>%
  dplyr::select(Year, Opium, Salt, Pawnshops, total) %>%
  pivot_longer(cols = Opium:Pawnshops,
               names_to = "Source",
               values_to = "Value") %>%
  ggplot(aes(x=Year, y = Value, linetype = Source, shape = Source)) +
  geom_point(size = 0.1) +
  geom_line() +
  theme_bw() +
  theme(axis.ticks.y.left = element_blank(),
        panel.grid.minor = element_blank(), 
        axis.title.y = element_blank(),
        panel.grid.major.x = element_blank(),
        legend.title = element_blank(),
        axis.title.x = element_blank(),
        axis.line.y.left = element_blank(),
        axis.line = element_line(colour = "black"),
        panel.border = element_blank(),
        panel.background = element_rect(fill = "transparent",colour = NA),
        plot.background = element_rect(fill = "transparent",colour = NA)) +
  theme(text=element_text(size=15))

ggsave("./_4_outputs/figures/figure_1a.tiff", plot = rev_share,  width = 5, height = 3, dpi = 300, compression = "lzw")
ggsave("./_4_outputs/figures/figure_1b.tiff", plot = rev_tot,  width = 5, height = 3, dpi = 300, compression = "lzw")


